<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="demo">
        <input type="text" placeholder="First Name" v-model="firstName"><br />
        <input type="text" placeholder="First Name" v-model="lastName"><br />
        <input type="text" :value='lastNum'><br>
        <input type="text" v-model='lastNum2'>
    </div>

    <script src="../js/vue.js"></script>
    <script>
        new Vue({
            el: '#demo',
            data: {
                firstName: '1',
                lastName: '2'
            },
            //这里定义方法(函数)
            methods: {

            },
            //计算 直接返回结果
            computed: {
                lastNum() {
                    return this.firstName + " " + this.lastName
                },
                lastNum2: {
                    get: function () {
                        return Number(this.firstName) + Number(this.lastName)
                    },
                    set: function (val) {
                        console.log(Number(val) / 2)
                        this.firstName = Number(val) / 2
                        this.lastName = Number(val) / 2
                        // this.firstName = left
                        // this.lastName = right
                    }
                }

            }
        })
    </script>
</body>

</html>